import json

from KHRPAFORM import share
from PySide2.QtCore import QObject, Slot


class Handler(QObject):

    # param初始化参数
    def __init__(self, param,*args, **kwargs):
        super(Handler, self).__init__(*args, **kwargs)
        self.param = param

    #@Slot是关键,是js中调用的接口,经测试,只能传一个参数,传对象参数时需要把它专为json字符串
    # 初始化方法
    @Slot(str, result=str)
    def initialize(self,param=None):
        print("initialize=param")
        return json.dumps(self.param)

    # 返回方法
    @Slot(str, result=str)
    def back(self,Index=None):
        share.SI.main.ui.stackedWidget.setCurrentIndex(int(Index))